package com.css.fxfzxczh.modules.seismicIntensityMap.seismicIntensityMapData.controller;

import com.alibaba.fastjson.JSONObject;
import com.css.fxfzxczh.base.response.RestResponse;
import com.css.fxfzxczh.modules.seismicIntensityMap.seismicIntensityMapData.entity.SeiIntMapData;
import com.css.fxfzxczh.modules.seismicIntensityMap.seismicIntensityMapData.queryParams.QueryParams;
import com.css.fxfzxczh.modules.seismicIntensityMap.seismicIntensityMapData.service.SeiIntMapDataService;
import com.css.fxfzxczh.modules.seismicIntensityMap.seismicIntensityMapData.vo.SeiIntMapDataVo;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.entity.EarEveManage;
import com.css.fxfzxczh.util.PlatformPageUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @author
 * @program
 * @description
 * @create 2022/8/8 10:39
 **/
@RestController
@RequestMapping("/seiIntMapData")
@Slf4j
public class SeiIntMapDataController {
    @Resource
    SeiIntMapDataService seiIntMapDataService;
    /**
     * 分页列表
     * @return
     */
    @GetMapping("/getTable")
    public RestResponse getTable(@RequestParam("xsemId")String xsemId){
        RestResponse restResponse=null;
        JSONObject jsonObject=new JSONObject();
        try{
            List<SeiIntMapDataVo> list = seiIntMapDataService.getTable(xsemId);
            jsonObject.put("message", "查询成功!");
            restResponse = RestResponse.succeed(list);
        }catch (Exception e){
            String errormessage="查询失败";
            log.error(errormessage,e);
            restResponse= RestResponse.fail(errormessage);
        }
        return restResponse;
    }

    /**
     * 保存
     *
     * @param seiIntMapData
     * @return
     */
    @PostMapping("/save")
    public RestResponse save(@RequestBody SeiIntMapData seiIntMapData) {
        RestResponse response = null;
        JSONObject jsonObject = new JSONObject();
        try {
            seiIntMapDataService.save(seiIntMapData);
            jsonObject.put("message", "保存成功");
            response = RestResponse.succeed(jsonObject);
        } catch (Exception e) {
            String errormessage = e.getMessage();
            if(StringUtils.isBlank(errormessage)) {
                errormessage = "保存失败";
            }
            log.error(errormessage,e);
            response=RestResponse.fail(errormessage);
        }
        return response;
    }

}
